package com.ucar.training.controller;

import com.ucar.training.domain.User;
import com.ucar.training.service.IUserService;
import com.ucar.training.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author XiongMM
 * @date 2019/7/30 09:30
 * @description 带着用户的信息去修改
 */
public class UpdateUIServlet extends HttpServlet {

    private IUserService userService = new UserServiceImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userName = request.getParameter("userName");
        //源对象
        User user = userService.selectOne(userName);
        //带着用户信息就去了
        request.setAttribute("myuser",user);
        request.getRequestDispatcher("/pages/update.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
